package com.loveyukari.utils;

import java.util.HashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.sf.json.JSONObject;

/**
*
*yangshaohua
*2017年8月15日上午11:28:12
**/
public class FanyiUtils {
	
	private static Logger LOG = LoggerFactory.getLogger(FanyiUtils.class);

	private static String icibaKey = "EEEFC5591D804143EA1E8BD5BA27A602";
	private static String icibaUrl = "http://dict-co.iciba.com/api/dictionary.php";
	public static JSONObject translate(String txt){
		HashMap<String, Object> params = new HashMap<String, Object>();
		params.put("type", "json");
		params.put("w", txt);
		params.put("key", icibaKey);
		try {
			String send = HttpUtils.sendGet(icibaUrl, params);
			JSONObject result = JSONObject.fromObject(send);
			return result;
		} catch (Exception e) {
			LOG.error(e.getMessage(),e);
		}
		return new JSONObject();
	}
	
	
}
